//
//  AccountViewModel.swift
//  mmda
//
//  Created by 李陆涛 on 2018/4/25.
//  Copyright © 2018年 mmda. All rights reserved.
//

import UIKit
import RxCocoa
import RxSwift

class AccountViewModel: NSObject {
    
    //    显示信息
    let message = Variable("")
    //    显示正在加载
//    let showLoading = Variable(false)
    
    var loadSuccess:(()->Void)?
    
    var user:User?
    
    func start() {
        
//        self.showLoading.value = true
        
        NetAPI.center.request(User.self) {
            
            [weak self] response, errmsg in
            guard let `self` = self else { return }
            
            guard let user = response as? User else {
                
                self.message.value = errmsg ?? "未知错误"
                return
            }
            
            self.user = user
            AppManager.share.user = user
            
            self.loadSuccess?()
        }
    }
}

